package com.xinhua.controller;


import com.alibaba.fastjson.JSONObject;
import com.xinhua.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张子艺
 * @since 2018-09-22
 */
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
    UserService userService;
    @RequestMapping("/main")
    public String main(){
        return  "login";
    }

    @RequestMapping("/select.html")
    public String select(){
        return  "/alert/select";
    }


    @RequestMapping("/login")
    @ResponseBody
    public String login(String userName,String passWord){
        Map map=new HashMap<>();
        map.put("user_name",userName);
        map.put("pass_word",passWord);
        Map map1=new HashMap<>();
        if(userService.selectByMap(map).size()>0){
            map1.put("success",true);
            String  json=JSONObject.toJSONString(map1);
            return  json;
        };
        map1.put("success",false);
        String  json=JSONObject.toJSONString(map1);
        return  json;
    }

}
